package com.broadsword.controller;


import com.alibaba.excel.EasyExcel;
import com.broadsword.excel.StudentDataListener;
import com.broadsword.excel.StudentExcel;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("message")
public class ExcelMessageController {


    @PostMapping("import-message")
    public String importMessage(MultipartFile file) {
        try {
            EasyExcel.read(file.getInputStream(), StudentExcel.class,new StudentDataListener()).sheet().doRead();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return "success";

    }




}
